package com.zzyl.controller.customer;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.controller.BaseController;
import com.zzyl.dto.ReservationDto;
import com.zzyl.entity.Reservation;
import com.zzyl.service.ReservationService;
import com.zzyl.vo.NursingProjectVo;
import com.zzyl.vo.ReservationVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

@RequestMapping("/customer/reservation")
@RestController
public class CostomerReservationController  extends BaseController {
  @Autowired
  private ReservationService reservationService;
  @GetMapping("cancelled-count")
  @ApiOperation("查询取消预约数")
  public ResponseResult getCount() {
    return ResponseResult.success(reservationService.getCount());
  }
  @GetMapping("countByTime")
  @ApiOperation("查询每个时间段预约次数")
  public ResponseResult<List<ReservationVo> > getCountByTime(@RequestParam Long time) {
    return ResponseResult.success(reservationService.getCountByTime(time));
  }

  @PostMapping
  public ResponseResult addReservation(@RequestBody Reservation ReservationDto) {
    reservationService.addReservation(ReservationDto);
    return ResponseResult.success();
  }
  @PutMapping("{id}/cancel")
  public ResponseResult cancel(@RequestBody Long id) {
    reservationService.cancel(id);
    return ResponseResult.success();
  }
  @GetMapping("page")
  public ResponseResult<PageResponse<ReservationVo>> getByPage(
          @ApiParam(value = "状态：0-禁用，1-启用")
          @RequestParam(value = "status", required = false) Integer status,
          @ApiParam(value = "当前页码")
          @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
          @ApiParam(value = "每页显示数量")
          @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
    PageResponse<ReservationVo> reservationPageInfo = reservationService.getByPage( status, pageNum, pageSize);
    return ResponseResult.success(reservationPageInfo);
  }
}
